﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DiBang.Common
{
    /// <summary>
    /// Base64编码解码
    /// </summary>
    public class Base64Encoding
    {
        /// <summary>
        /// Base64编码,防止修改
        /// </summary>
        /// <param name="strNormal">正常字符串</param>
        /// <returns>Base64的字符串</returns>
        public static string BaseEncoding(string strNormal)
        {
            byte[] bBase = Encoding.Unicode.GetBytes(strNormal);
            //string strBase = Convert.ToBase64String(bBase);
            return Convert.ToBase64String(bBase); ;
        }

        /// <summary>
        /// Base64解码
        /// </summary>
        /// <param name="strBase">Base64的字符串</param>
        /// <returns>正常字符串</returns>
        public static string UnBaseEnconding(string strBase)
        {
            byte[] bUnbase = Convert.FromBase64String(strBase);
            return Encoding.Unicode.GetString(bUnbase);
        }
    }
}
